package com.mc.provider.test;

import com.github.jsonzou.jmockdata.JMockData;
import com.mc.provider.generate.entity.Blog;
import com.mc.provider.generate.mapper.BlogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Mic Core 项目的 非服务类对外的 demo
 *
 * @author Liu Chunfu
 * @date 2018-04-09 下午8:21
 **/
@RestController
@RequestMapping("/demo")
public class DemoController {

    @Autowired
    private BlogMapper blogMapper;

    @GetMapping("/blog")
    public List<Blog> findBlogList() {
        return blogMapper.selectAll();
    }

    @PostMapping("/blog")
    public boolean saveBlob() {
        for (int i = 0; i < 10; i++) {
            Blog blog = JMockData.mockSimpleType(Blog.class);
            blog.setId(null);
            blogMapper.insertSelective(blog);
        }
        return true;
    }
}
